//
//  PauseButton.m
//  iFly
//
//  Created by Petko Haydushki on 12/8/14.
//  Copyright (c) 2014 TeamDifferent. All rights reserved.
//
#import "PauseButton.h"
#import "Constants.h"
#import "SoundHandler.h"

@interface PauseButton ()

@property BOOL gameIsPaused;
@property BOOL updating;

@end

@implementation PauseButton
static float screenScaleCoef;

+(instancetype)pauseButtonWithPosition:(CGPoint)position inScene:(SKScene *)scene {
    screenScaleCoef= scene.size.height/640;
    PauseButton* pauseButton=[self spriteNodeWithImageNamed:pauseButtonImage];
    [pauseButton setScale:pauseButtonScaling* screenScaleCoef];
    pauseButton.name=@"pause";
    pauseButton.position=CGPointMake(scene.size.width - pauseButtonOffset* screenScaleCoef, scene.size.height -pauseButtonOffset*screenScaleCoef);
    pauseButton.isGamePaused=NO;
    pauseButton.isParalaxPaused = NO;
    //to always keep the pause on top
    pauseButton.zPosition = 1;
    return pauseButton;
}

-(void) handlePause {

    [self setTexture:[SKTexture textureWithImageNamed:playButtonImage]];
    self.parent.scene.paused=YES;
    self.isGamePaused=YES;
    self.isParalaxPaused = YES;
    self.updating=NO;
    //[[SoundHandler sharedSoundPlayer] pauseBackgroundMusic];

    
    
}
-(void) handleUnPause {
    
    self.parent.scene.paused = NO;
     self.isGamePaused= NO;
    self.updating=YES;
    [self setTexture:[SKTexture textureWithImageNamed:pauseButtonImage]];
    //[[SoundHandler sharedSoundPlayer] resumeBackgroundMusic];

}

@end
